﻿using System;
using System.Xml.Serialization;

namespace DE.Sdc.SharePoint.SPContentStructure.Common
{
    [Serializable]
    public class IdentifiedElement
    {
        private string _title;
        private string _id;
        private string _name;
        private string _url;

        [XmlAttribute]
        public string Identifier { get; set; }

        [XmlAttribute]
        public IdentifierType IdentifierType { get; set; }

        [XmlAttribute]
        public virtual ActionType Action { get; set; }

        [XmlAttribute]
        public string Title
        {
            get { return _title ?? (IdentifierType == IdentifierType.Title ? Identifier : null); }
            set
            {
                _title = value;
            }
        }

        [XmlAttribute]
        public string Id
        {
            get { return _id ?? (IdentifierType == IdentifierType.Id ? Identifier : null); }
            set
            {
                _id = value;
            }
        }

        [XmlAttribute]
        public string Name
        {
            get { return _name ?? (IdentifierType == IdentifierType.Name ? Identifier : null); }
            set
            {
                _name = value;
            }
        }

        [XmlAttribute]
        public string Url
        {
            get { return _url ?? (IdentifierType == IdentifierType.Url ? Identifier : null); }
            set
            {
                _url = value;
            }
        }
    }
}
